<template>
	<view>
		<musichead title="网易云音乐" :icon="false"></musichead>
		<view class="container">
			<scroll-view scroll-y="true">
				<view class="index-search" @tap="handleToSearch">
					<text class="iconfont icon-fangdajing"></text>
					<input type="text" placeholder="搜索歌曲" />
				</view>
				<view class="index-list">
					<view class="index-list-item" v-for="(item, index) of topList" :key="index">
						<view class="index-list-img" @tap="handleToList(item.id)">
							<image :src="item.coverImgUrl" alt="" />
							<text>{{item.updateFrequency}}</text>
						</view>
						<view class="index-list-text">
							<view class="" v-for="(song, idx) of item.tracks" :key="idx">
								{{idx+1}}.{{song.first}} - {{song.second}}
							</view>
						</view>
					</view>
					<!-- <view class="index-list-item">
						<view class="index-list-img">
							<img src="@/static/netease.jpeg" alt="" />
							<text>每日更新</text>
						</view>
						<view class="index-list-text">
							<view class="">
								1.与我无关 - 阿宇
							</view>
							<view class="">
								2.与我无关 - 阿宇
							</view>
							<view class="">
								3.与我无关 - 阿宇
							</view>
						</view>
					</view> -->
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import '@/common/iconfont.css';
	import musichead from '@/components/musichead/musichead.vue'
	import {
		topList
	} from '@/common/api.js'
	export default {
		data() {
			return {
				topList: []
			}
		},
		components: {
			musichead
		},
		onLoad() {
			topList().then((res) => {
				if (res.length) {
					console.log(res);
					this.topList = res;
				}
			});
		},
		methods: {
			handleToList(id){
				uni.navigateTo({
					url: '/pages/list/list?id=' + id,
				});
			},
			handleToSearch(){
				uni.navigateTo({
					url: '/pages/search/search'
				})
			},
		}
	}
</script>
<style scoped>
	.index-search {
		width: 90%;
		height: 70rpx;
		margin: 70rpx 30rpx 30rpx 30rpx;
		display: flex;
		justify-content: flex-start;
		background-color: #f7f7f7;
		align-items: center;
		border-radius: 35rpx;
		padding-left: 20rpx;
		box-sizing: border-box;
	}

	.index-search input {
		flex: 1;
		color: #666;
		margin-left: 26rpx;
		font-size: 28rpx;
	}

	.index-search text {
		color: #666;
		font-size: 26rpx;
		margin-left: 26rpx;
	}

	.index-list {
		margin: 0 30rpx;
	}

	.index-list-item {
		display: flex;
		margin-bottom: 34rpx;
	}

	.index-list-img {
		width: 212rpx;
		height: 212rpx;
		position: relative;
		border-radius: 20rpx;
		overflow: hidden;
		margin-right: 22rpx;
	}

	.index-list-img image {
		width: 100%;
		height: 100%;

	}

	.index-list-img text {
		position: absolute;
		bottom: 16rpx;
		left: 20rpx;
		font-size: 20rpx;
		color: #f7f7f7;
	}

	.index-list-text {
		font-size: 24rpx;
		line-height: 66rpx;
		width: calc(100% - 234rpx - 60rpx);

		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		overflow: hidden;
	}

	.index-list-text text {}
</style>